<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #box {
            text-align: center;
        }

        #box #btn {
            margin: auto;
            width: 50px;
            height: 50px;
            line-height: 50px;
            background-color: #ddd;
            border-radius: 100%;
            color: #fff;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div id="box">
        <div id="btn">开</div>
        <img id="img" src="" alt="">
    </div>

    <script>
        (function () {
            var btn = document.querySelector('#btn');
            var img = document.querySelector('#img');
            btn.onclick=function(){
                console.log("this",this);
                if(this.innerHTML == "开"){
                    img.src = "img/pic_bulbon.gif";
                    this.innerHTML = "关";
                    this.style.background = "green";
                }else{
                    img.src = "img/pic_bulboff.gif";
                    this.innerHTML = "开";
                    this.style.background = "#ddd";
                }
            }
        }());
    </script>
</body>

</html>